// -*- c-basic-offset: 2 default-tab-width: 2 indent-tabs-mode: t -*-
// vim: autoindent tabstop=2 noexpandtab shiftwidth=2 softtabstop=2
#include "util.h"
#include "Array.h"

using namespace R;
/*
 * Value box are used to box results while avoiding allocations
 */

#define FLAG_Logical 1
#define FLAG_Int 2
#define FLAG_Double 4
#define FLAG_String 8

#define DECLARE_FIELDS(__type, __parent, data, ...)\
	data _##__type;
#define DECLARE_METHODS(__type, __parent, data, ...)\
	template <> \
	void ValueBox::set(data val){ used |= FLAG_##__type ;  _##__type = val; } \
	template <> \
	data ValueBox::get(){ return _##__type; } \
	template <> \
	bool ValueBox::has(data val){ return used & FLAG_##__type ; } \

class ValueBox {
	public:
	uint32_t used;

	template <typename T>
	T get(){ nyi_fatal(); } // will never be implemented 
	template <typename T>
	void set(T val){ nyi_fatal(); } // will never be implemented 
	template <typename T>
	bool has(T val){ nyi_fatal(); } // will never be implemented 

	on_number_and_string_arrays(DECLARE_FIELDS)
};
on_number_and_string_arrays(DECLARE_METHODS)
